Imports System

Imports System.Data.SqlClient 'Remove
Imports System.Data.OleDb

Imports System.Globalization
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Runtime.ConnectionManager

Public Class AuditForm
     Inherits Form

     Private _sVersion As String = "1.0.0.23"

#Region "Class Declares"
     Private _taskHostValue As TaskHost
     Private _oAuditConfig As New AuditConfig
     Private _oPkg As New Package
     Private _oParentPkg As New Package
     Private _oAuditTables As New AuditTables

     'State Variables
     Private _oTableListPopulated As Boolean = False
     Private _oUnselectedVariableObject As AuditVariable = New AuditVariable("--- None Selected ---", "", "", "")

     'Basic Containers
     'Private _oAuditConnections As New AuditConnections
     'Private _oAuditIntVariables As New AuditVariables
     'Private _oAuditMixedVariables As New AuditVariables
     'Private _oAuditParentVariables As New AuditVariables

     'Individual Screen Connections
     Private _oAuditAuditDBConnConnections As New AuditConnections 'cmbAuditDBConn
     Private _oAuditAuditedDBConnConnections As New AuditConnections 'cmbAuditedDBConn

     'Individual Screen Variables
     Private _oAuditParentPackageExecutionIdVariables As New AuditVariables 'cmbParentPackageExecutionIdVariable
     Private _oAuditThisPackageExecutionIdVariables As New AuditVariables 'cmbThisPackageExecutionIdVariable
     Private _oAuditPackageExecutionVariables As New AuditVariables 'cmbPackageExecutionVariable
     Private _oAuditTableAuditKeyIdVariables As New AuditVariables 'cmbTableAuditKeyIdVariable
     Private _oAuditStartRowCountVariables As New AuditVariables 'cmbStartRowCountVariable
     Private _oAuditInsertRowCountVariables As New AuditVariables 'cmbInsertRowCountVariable
     Private _oAuditUpdateRowCountVariables As New AuditVariables 'cmbUpdateRowCountVariable
     Private _oAuditDeleteRowCountVariables As New AuditVariables 'cmbDeleteRowCountVariable
     Private _oAuditErrorRowCountVariables As New AuditVariables 'cmbErrorRowCountVariable
     Private _oAuditEndingRowCountVariables As New AuditVariables 'cmbEndingRowCountVariable
     Private _oAuditTableActionStatusVariables As New AuditVariables 'cmbTableActionStatusVariable
#End Region

     Public Sub New(ByVal taskHost As TaskHost)
          InitializeComponent()

          Me._taskHostValue = taskHost

          Me.Text = Me.Text & " - Version: " & _sVersion

          'Do setup of screen from variables.
          _oPkg = CType(_taskHostValue.Parent.Site.Component, Package)

          'Get Configuration Information

          GetConnectionsFromPackage()
          'GenConnectionContainers()

          GetIntVariablesFromPackage()
          GetMixedVariablesFromPackage()
          'GenVariableContainers()

          'Setup the screen
          PopulateInitialScreen()

          'We do this here for a reason, we want to do it after the initial setup of the screen.
          'Get Config Data Object from Host
          '_oAuditConfig = CType(_taskHostValue.InnerObject, NCL.SSIS.ControlFlow.Audit).AuditConfiguration
          '_oAuditConfig = CType(_taskHostValue.Properties("AuditConfiguration").GetValue(_taskHostValue), AuditConfig)
          PopulateAuditConfigFromTaskHostProperties()

          'Get the user selected name from the task host
          _oAuditConfig.UserSelectedTaskName = _taskHostValue.Name

          'Adjust screen to match previously setup properties
          PopulateScreenFromConfig()

     End Sub

#Region "Get Set AuditConfig from Properties"
     Private Sub PopulateAuditConfigFromTaskHostProperties()
          _oAuditConfig.AuditDatabaseConnectionName = CType(_taskHostValue.Properties("AuditDatabaseConnectionName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditDatabaseConnectionGUID = CType(_taskHostValue.Properties("AuditDatabaseConnectionGUID").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditPackageExecutionMode = CType(_taskHostValue.Properties("AuditPackageExecutionMode").GetValue(_taskHostValue), AuditExecutionMode)
          _oAuditConfig.AuditPackageRunAsMaster = CType(_taskHostValue.Properties("AuditPackageRunAsMaster").GetValue(_taskHostValue), AuditRunAsMaster)
          _oAuditConfig.AuditParentPackageExecutionIdVariableName = CType(_taskHostValue.Properties("AuditParentPackageExecutionIdVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditThisPackageExecutionIdVariableName = CType(_taskHostValue.Properties("AuditThisPackageExecutionIdVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditPackageExecutionStatus = CType(_taskHostValue.Properties("AuditPackageExecutionStatus").GetValue(_taskHostValue), AuditExecutionStatus)
          _oAuditConfig.AuditPackageExecutionVariableName = CType(_taskHostValue.Properties("AuditPackageExecutionVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableExecutionMode = CType(_taskHostValue.Properties("AuditTableExecutionMode").GetValue(_taskHostValue), AuditExecutionMode)
          _oAuditConfig.AuditedDatabaseConnectionName = CType(_taskHostValue.Properties("AuditedDatabaseConnectionName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditedDatabaseConnectionGUID = CType(_taskHostValue.Properties("AuditedDatabaseConnectionGUID").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableExecutionIdVariableName = CType(_taskHostValue.Properties("AuditTableExecutionIdVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableSchemaName = CType(_taskHostValue.Properties("AuditTableSchemaName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableName = CType(_taskHostValue.Properties("AuditTableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableStartRowCountAction = CType(_taskHostValue.Properties("AuditTableStartRowCountAction").GetValue(_taskHostValue), AuditTableAction)
          _oAuditConfig.AuditTableStartRowCountVariableName = CType(_taskHostValue.Properties("AuditTableStartRowCountVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableStartRowCountQuery = CType(_taskHostValue.Properties("AuditTableStartRowCountQuery").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableUpdateRowCountVariableName = CType(_taskHostValue.Properties("AuditTableUpdateRowCountVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableInsertRowCountAction = CType(_taskHostValue.Properties("AuditTableInsertRowCountAction").GetValue(_taskHostValue), AuditTableAction)
          _oAuditConfig.AuditTableInsertRowCountVariableName = CType(_taskHostValue.Properties("AuditTableInsertRowCountVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableInsertRowCountQuery = CType(_taskHostValue.Properties("AuditTableInsertRowCountQuery").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableDeleteRowCountVariableName = CType(_taskHostValue.Properties("AuditTableDeleteRowCountVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableErrorRowCountVariableName = CType(_taskHostValue.Properties("AuditTableErrorRowCountVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableEndingRowCountAction = CType(_taskHostValue.Properties("AuditTableEndingRowCountAction").GetValue(_taskHostValue), AuditTableAction)
          _oAuditConfig.AuditTableEndingRowCountVariableName = CType(_taskHostValue.Properties("AuditTableEndingRowCountVariableName").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableEndingRowCountQuery = CType(_taskHostValue.Properties("AuditTableEndingRowCountQuery").GetValue(_taskHostValue), String)
          _oAuditConfig.AuditTableExecutionStatus = CType(_taskHostValue.Properties("AuditTableExecutionStatus").GetValue(_taskHostValue), AuditExecutionStatus)
          _oAuditConfig.AuditTableExecutionVariableName = CType(_taskHostValue.Properties("AuditTableExecutionVariableName").GetValue(_taskHostValue), String)
     End Sub

     Private Sub PopulateTaskHostPropertiesFromAuditConfig()
          _taskHostValue.Properties("AuditDatabaseConnectionName").SetValue(_taskHostValue, _oAuditConfig.AuditDatabaseConnectionName)
          _taskHostValue.Properties("AuditDatabaseConnectionGUID").SetValue(_taskHostValue, _oAuditConfig.AuditDatabaseConnectionGUID)
          _taskHostValue.Properties("AuditPackageExecutionMode").SetValue(_taskHostValue, CType(_oAuditConfig.AuditPackageExecutionMode, Integer))
          _taskHostValue.Properties("AuditPackageRunAsMaster").SetValue(_taskHostValue, CType(_oAuditConfig.AuditPackageRunAsMaster, Integer))
          _taskHostValue.Properties("AuditParentPackageExecutionIdVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditParentPackageExecutionIdVariableName)
          _taskHostValue.Properties("AuditThisPackageExecutionIdVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditThisPackageExecutionIdVariableName)
          _taskHostValue.Properties("AuditPackageExecutionStatus").SetValue(_taskHostValue, CType(_oAuditConfig.AuditPackageExecutionStatus, Integer))
          _taskHostValue.Properties("AuditPackageExecutionVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditPackageExecutionVariableName)
          _taskHostValue.Properties("AuditTableExecutionMode").SetValue(_taskHostValue, CType(_oAuditConfig.AuditTableExecutionMode, Integer))
          _taskHostValue.Properties("AuditedDatabaseConnectionName").SetValue(_taskHostValue, _oAuditConfig.AuditedDatabaseConnectionName)
          _taskHostValue.Properties("AuditedDatabaseConnectionGUID").SetValue(_taskHostValue, _oAuditConfig.AuditedDatabaseConnectionGUID)
          _taskHostValue.Properties("AuditTableExecutionIdVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableExecutionIdVariableName)
          _taskHostValue.Properties("AuditTableSchemaName").SetValue(_taskHostValue, _oAuditConfig.AuditTableSchemaName)
          _taskHostValue.Properties("AuditTableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableName)
          _taskHostValue.Properties("AuditTableStartRowCountAction").SetValue(_taskHostValue, CType(_oAuditConfig.AuditTableStartRowCountAction, Integer))
          _taskHostValue.Properties("AuditTableStartRowCountVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableStartRowCountVariableName)
          _taskHostValue.Properties("AuditTableStartRowCountQuery").SetValue(_taskHostValue, _oAuditConfig.AuditTableStartRowCountQuery)
          _taskHostValue.Properties("AuditTableUpdateRowCountVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableUpdateRowCountVariableName)
          _taskHostValue.Properties("AuditTableInsertRowCountAction").SetValue(_taskHostValue, CType(_oAuditConfig.AuditTableInsertRowCountAction, Integer))
          _taskHostValue.Properties("AuditTableInsertRowCountVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableInsertRowCountVariableName)
          _taskHostValue.Properties("AuditTableInsertRowCountQuery").SetValue(_taskHostValue, _oAuditConfig.AuditTableInsertRowCountQuery)
          _taskHostValue.Properties("AuditTableDeleteRowCountVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableDeleteRowCountVariableName)
          _taskHostValue.Properties("AuditTableErrorRowCountVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableErrorRowCountVariableName)
          _taskHostValue.Properties("AuditTableEndingRowCountAction").SetValue(_taskHostValue, CType(_oAuditConfig.AuditTableEndingRowCountAction, Integer))
          _taskHostValue.Properties("AuditTableEndingRowCountVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableEndingRowCountVariableName)
          _taskHostValue.Properties("AuditTableEndingRowCountQuery").SetValue(_taskHostValue, _oAuditConfig.AuditTableEndingRowCountQuery)
          _taskHostValue.Properties("AuditTableExecutionStatus").SetValue(_taskHostValue, CType(_oAuditConfig.AuditTableExecutionStatus, Integer))
          _taskHostValue.Properties("AuditTableExecutionVariableName").SetValue(_taskHostValue, _oAuditConfig.AuditTableExecutionVariableName)
          _taskHostValue.Properties("UserSelectedTaskName").SetValue(_taskHostValue, _oAuditConfig.UserSelectedTaskName)
     End Sub
#End Region

#Region "Main Screen Control"
#Region "Overall Main Screen Control"
     Private Sub PopulateInitialScreen()
          cmbAuditDBConn.DataSource = _oAuditAuditDBConnConnections '_oAuditConnections
          cmbAuditDBConn.ValueMember = "ConnectionGUID"
          cmbAuditDBConn.DisplayMember = "ConnectionName"
          cmbAuditDBConn.SelectedIndex = -1
          'cmbAuditDBConn.SelectedIndex = cmbAuditDBConn.Items.IndexOf(_oUnselectedVariableObject)

          cmbAuditedDBConn.DataSource = _oAuditAuditedDBConnConnections '_oAuditConnections
          cmbAuditedDBConn.ValueMember = "ConnectionGUID"
          cmbAuditedDBConn.DisplayMember = "ConnectionName"
          cmbAuditedDBConn.SelectedIndex = -1
          'cmbAuditedDBConn.SelectedIndex = cmbAuditedDBConn.Items.IndexOf(_oUnselectedVariableObject)

          cmbParentPackageExecutionIdVariable.DataSource = _oAuditParentPackageExecutionIdVariables '_oAuditParentVariables
          cmbParentPackageExecutionIdVariable.ValueMember = "VariableName"
          cmbParentPackageExecutionIdVariable.DisplayMember = "VariableDisplayName"
          'cmbParentPackageExecutionIdVariable.SelectedIndex = -1
          cmbParentPackageExecutionIdVariable.SelectedIndex = cmbParentPackageExecutionIdVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbThisPackageExecutionIdVariable.DataSource = _oAuditThisPackageExecutionIdVariables '_oAuditIntVariables
          cmbThisPackageExecutionIdVariable.ValueMember = "VariableName"
          cmbThisPackageExecutionIdVariable.DisplayMember = "VariableDisplayName"
          'cmbThisPackageExecutionIdVariable.SelectedIndex = -1
          cmbThisPackageExecutionIdVariable.SelectedIndex = cmbThisPackageExecutionIdVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbPackageExecutionVariable.DataSource = _oAuditPackageExecutionVariables '_oAuditMixedVariables
          cmbPackageExecutionVariable.ValueMember = "VariableName"
          cmbPackageExecutionVariable.DisplayMember = "VariableDisplayName"
          'cmbPackageExecutionVariable.SelectedIndex = -1
          cmbPackageExecutionVariable.SelectedIndex = cmbPackageExecutionVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbTableAuditKeyIdVariable.DataSource = _oAuditTableAuditKeyIdVariables '_oAuditIntVariables
          cmbTableAuditKeyIdVariable.ValueMember = "VariableName"
          cmbTableAuditKeyIdVariable.DisplayMember = "VariableDisplayName"
          'cmbTableAuditKeyIdVariable.SelectedIndex = -1
          cmbTableAuditKeyIdVariable.SelectedIndex = cmbTableAuditKeyIdVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbTableName.DataSource = _oAuditTables
          cmbTableName.ValueMember = "QualifiedTableName"
          cmbTableName.DisplayMember = "QualifiedTableName"
          cmbTableName.SelectedIndex = -1

          cmbTableActionStatusVariable.DataSource = _oAuditTableActionStatusVariables '_oAuditMixedVariables
          cmbTableActionStatusVariable.ValueMember = "VariableName"
          cmbTableActionStatusVariable.DisplayMember = "VariableDisplayName"
          'cmbTableActionStatusVariable.SelectedIndex = -1
          cmbTableActionStatusVariable.SelectedIndex = cmbTableActionStatusVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbStartRowCountVariable.DataSource = _oAuditStartRowCountVariables '_oAuditIntVariables
          cmbStartRowCountVariable.ValueMember = "VariableName"
          cmbStartRowCountVariable.DisplayMember = "VariableDisplayName"
          'cmbStartRowCountVariable.SelectedIndex = -1
          cmbStartRowCountVariable.SelectedIndex = cmbStartRowCountVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbInsertRowCountVariable.DataSource = _oAuditInsertRowCountVariables '_oAuditIntVariables
          cmbInsertRowCountVariable.ValueMember = "VariableName"
          cmbInsertRowCountVariable.DisplayMember = "VariableDisplayName"
          'cmbInsertRowCountVariable.SelectedIndex = -1
          cmbInsertRowCountVariable.SelectedIndex = cmbInsertRowCountVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbUpdateRowCountVariable.DataSource = _oAuditUpdateRowCountVariables '_oAuditIntVariables
          cmbUpdateRowCountVariable.ValueMember = "VariableName"
          cmbUpdateRowCountVariable.DisplayMember = "VariableDisplayName"
          'cmbUpdateRowCountVariable.SelectedIndex = -1
          cmbUpdateRowCountVariable.SelectedIndex = cmbUpdateRowCountVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbDeleteRowCountVariable.DataSource = _oAuditDeleteRowCountVariables '_oAuditIntVariables
          cmbDeleteRowCountVariable.ValueMember = "VariableName"
          cmbDeleteRowCountVariable.DisplayMember = "VariableDisplayName"
          'cmbDeleteRowCountVariable.SelectedIndex = -1
          cmbDeleteRowCountVariable.SelectedIndex = cmbDeleteRowCountVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbErrorRowCountVariable.DataSource = _oAuditErrorRowCountVariables '_oAuditIntVariables
          cmbErrorRowCountVariable.ValueMember = "VariableName"
          cmbErrorRowCountVariable.DisplayMember = "VariableDisplayName"
          'cmbErrorRowCountVariable.SelectedIndex = -1
          cmbErrorRowCountVariable.SelectedIndex = cmbErrorRowCountVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbEndingRowCountVariable.DataSource = _oAuditEndingRowCountVariables '_oAuditIntVariables
          cmbEndingRowCountVariable.ValueMember = "VariableName"
          cmbEndingRowCountVariable.DisplayMember = "VariableDisplayName"
          'cmbEndingRowCountVariable.SelectedIndex = -1
          cmbEndingRowCountVariable.SelectedIndex = cmbEndingRowCountVariable.Items.IndexOf(_oUnselectedVariableObject)

          cmbPackageExecutionStatus.SelectedIndex = 1 'Package Failed Execution
          cmbTableActionStatus.SelectedIndex = 1 'Table Processing Failed
          cmbStartRowCountAction.SelectedIndex = 0 'Auto Count
          cmbInsertRowCountAction.SelectedIndex = 0 'Auto Count
          cmbEndingRowCountAction.SelectedIndex = 0 'Auto Count

          rbRunAsMasterYes.Checked = False
          rbRunAsMasterAlways.Checked = False
          rbRunAsMasterNo.Checked = True
          cmbAuditPackageExecutionMode.SelectedIndex = 2
          cmbAuditTableExecutionMode.SelectedIndex = 2
          btnRefreshTableList.Hide()
     End Sub

     Private Sub PopulateScreenFromConfig()
          Dim _iPos As Integer
          Dim _oAuditConn As AuditConnection

          'cmbAuditDBConn
          If Not _oAuditConfig.AuditDatabaseConnectionName = "" Then
               For _iPos = 0 To cmbAuditDBConn.Items.Count - 1
                    _oAuditConn = CType(cmbAuditDBConn.Items(_iPos), AuditConnection)

                    If _oAuditConn.ConnectionName = _oAuditConfig.AuditDatabaseConnectionName Then
                         cmbAuditDBConn.SelectedIndex = _iPos
                         Exit For
                    ElseIf _oAuditConn.ConnectionGUID = _oAuditConfig.AuditDatabaseConnectionGUID Then
                         cmbAuditDBConn.SelectedIndex = _iPos
                         Exit For
                    End If
               Next
          End If

          'cmbAuditPackageExecutionMode
          Select Case _oAuditConfig.AuditPackageExecutionMode
               Case AuditExecutionMode.ExecStart
                    cmbAuditPackageExecutionMode.SelectedIndex = 0
               Case AuditExecutionMode.ExecEnd
                    cmbAuditPackageExecutionMode.SelectedIndex = 1
               Case AuditExecutionMode.None
                    cmbAuditPackageExecutionMode.SelectedIndex = 2
          End Select

          'rbRunAsMasterYes - rbRunAsMasterNo - rbRunAsMasterAlways
          Select Case _oAuditConfig.AuditPackageRunAsMaster
               Case AuditRunAsMaster.Yes
                    rbRunAsMasterYes.Checked = True
                    'rbRunAsMasterNo
                    'rbRunAsMasterAlways
               Case AuditRunAsMaster.No
                    'rbRunAsMasterYes
                    rbRunAsMasterNo.Checked = True
                    'rbRunAsMasterAlways
               Case AuditRunAsMaster.Always
                    'rbRunAsMasterYes
                    'rbRunAsMasterNo
                    rbRunAsMasterAlways.Checked = True
               Case AuditRunAsMaster.NotApplicable
                    rbRunAsMasterYes.Checked = False
                    rbRunAsMasterNo.Checked = False
                    rbRunAsMasterAlways.Checked = False
          End Select

          'cmbParentPackageExecutionIdVariable
          'cmbParentPackageExecutionIdVariable.SelectedIndex = cmbParentPackageExecutionIdVariable.Items.IndexOf(_oAuditConfig.AuditParentPackageExecutionIdVariableName)
          cmbParentPackageExecutionIdVariable.SelectedIndex = FindIndexForVariableComboBox("cmbParentPackageExecutionIdVariable", _oAuditConfig.AuditParentPackageExecutionIdVariableName)

          'cmbThisPackageExecutionIdVariable
          cmbThisPackageExecutionIdVariable.SelectedIndex = FindIndexForVariableComboBox("cmbThisPackageExecutionIdVariable", _oAuditConfig.AuditThisPackageExecutionIdVariableName)

          'cmbPackageExecutionStatus
          Select Case _oAuditConfig.AuditPackageExecutionStatus
               Case AuditExecutionStatus.Success
                    cmbPackageExecutionStatus.SelectedIndex = 0
               Case AuditExecutionStatus.Fail
                    cmbPackageExecutionStatus.SelectedIndex = 1
               Case AuditExecutionStatus.GetFromVariable
                    cmbPackageExecutionStatus.SelectedIndex = 2
               Case AuditExecutionStatus.NotApplicable
                    cmbPackageExecutionStatus.SelectedIndex = -1
          End Select

          'cmbPackageExecutionVariable
          cmbPackageExecutionVariable.SelectedIndex = FindIndexForVariableComboBox("cmbPackageExecutionVariable", _oAuditConfig.AuditPackageExecutionVariableName)

          'cmbAuditTableExecutionMode
          Select Case _oAuditConfig.AuditTableExecutionMode
               Case AuditExecutionMode.ExecStart
                    cmbAuditTableExecutionMode.SelectedIndex = 0
               Case AuditExecutionMode.ExecEnd
                    cmbAuditTableExecutionMode.SelectedIndex = 1
               Case AuditExecutionMode.None
                    cmbAuditTableExecutionMode.SelectedIndex = 2
          End Select

          'cmbAuditedDBConn
          If Not _oAuditConfig.AuditedDatabaseConnectionName = "" Then
               For _iPos = 0 To cmbAuditedDBConn.Items.Count - 1
                    _oAuditConn = CType(cmbAuditedDBConn.Items(_iPos), AuditConnection)

                    If _oAuditConn.ConnectionName = _oAuditConfig.AuditedDatabaseConnectionName Then
                         cmbAuditedDBConn.SelectedIndex = _iPos
                         Exit For
                    ElseIf _oAuditConn.ConnectionGUID = _oAuditConfig.AuditedDatabaseConnectionGUID Then
                         cmbAuditedDBConn.SelectedIndex = _iPos
                         Exit For
                    End If
               Next
          End If

          'cmbTableAuditKeyIdVariable
          cmbTableAuditKeyIdVariable.SelectedIndex = FindIndexForVariableComboBox("cmbTableAuditKeyIdVariable", _oAuditConfig.AuditTableExecutionIdVariableName)

          'cmbTableName
          cmbTableName.SelectedIndex = cmbTableName.Items.IndexOf(New AuditTable(_oAuditConfig.AuditTableSchemaName, _oAuditConfig.AuditTableName))

          'cmbStartRowCountAction
          Select Case _oAuditConfig.AuditTableStartRowCountAction
               Case AuditTableAction.AutoCount
                    cmbStartRowCountAction.SelectedIndex = 0
               Case AuditTableAction.GetCountByQuery
                    cmbStartRowCountAction.SelectedIndex = 2
               Case AuditTableAction.GetCountFromVariable
                    cmbStartRowCountAction.SelectedIndex = 1
               Case AuditTableAction.NotApplicable
                    cmbStartRowCountAction.SelectedIndex = -1
          End Select

          'cmbStartRowCountVariable
          cmbStartRowCountVariable.SelectedIndex = FindIndexForVariableComboBox("cmbStartRowCountVariable", _oAuditConfig.AuditTableStartRowCountVariableName)

          'txtStartRowCountQuery
          txtStartRowCountQuery.Text = _oAuditConfig.AuditTableStartRowCountQuery

          'cmbUpdateRowCountVariable
          cmbUpdateRowCountVariable.SelectedIndex = FindIndexForVariableComboBox("cmbUpdateRowCountVariable", _oAuditConfig.AuditTableUpdateRowCountVariableName)

          'cmbInsertRowCountAction
          Select Case _oAuditConfig.AuditTableInsertRowCountAction
               Case AuditTableAction.AutoCount
                    cmbInsertRowCountAction.SelectedIndex = 0
               Case AuditTableAction.GetCountByQuery
                    cmbInsertRowCountAction.SelectedIndex = 2
               Case AuditTableAction.GetCountFromVariable
                    cmbInsertRowCountAction.SelectedIndex = 1
               Case AuditTableAction.NotApplicable
                    cmbInsertRowCountAction.SelectedIndex = -1
          End Select

          'cmbInsertRowCountVariable
          cmbInsertRowCountVariable.SelectedIndex = FindIndexForVariableComboBox("cmbInsertRowCountVariable", _oAuditConfig.AuditTableInsertRowCountVariableName)

          'txtInsertRowCountQuery
          txtInsertRowCountQuery.Text = _oAuditConfig.AuditTableInsertRowCountQuery

          'cmbDeleteRowCountVariable
          cmbDeleteRowCountVariable.SelectedIndex = FindIndexForVariableComboBox("cmbDeleteRowCountVariable", _oAuditConfig.AuditTableDeleteRowCountVariableName)

          'cmbErrorRowCountVariable
          cmbErrorRowCountVariable.SelectedIndex = FindIndexForVariableComboBox("cmbErrorRowCountVariable", _oAuditConfig.AuditTableErrorRowCountVariableName)

          'cmbEndingRowCountAction
          Select Case _oAuditConfig.AuditTableEndingRowCountAction
               Case AuditTableAction.AutoCount
                    cmbEndingRowCountAction.SelectedIndex = 0
               Case AuditTableAction.GetCountByQuery
                    cmbEndingRowCountAction.SelectedIndex = 2
               Case AuditTableAction.GetCountFromVariable
                    cmbEndingRowCountAction.SelectedIndex = 1
               Case AuditTableAction.NotApplicable
                    cmbEndingRowCountAction.SelectedIndex = -1
          End Select

          'cmbEndingRowCountVariable
          cmbEndingRowCountVariable.SelectedIndex = FindIndexForVariableComboBox("cmbEndingRowCountVariable", _oAuditConfig.AuditTableEndingRowCountVariableName)

          'txtEndingRowCountQuery
          txtEndingRowCountQuery.Text = _oAuditConfig.AuditTableEndingRowCountQuery

          'cmbTableActionStatus
          Select Case _oAuditConfig.AuditTableExecutionStatus
               Case AuditExecutionStatus.Success
                    cmbTableActionStatus.SelectedIndex = 0
               Case AuditExecutionStatus.Fail
                    cmbTableActionStatus.SelectedIndex = 1
               Case AuditExecutionStatus.GetFromVariable
                    cmbTableActionStatus.SelectedIndex = 2
               Case AuditExecutionStatus.NotApplicable
                    cmbTableActionStatus.SelectedIndex = -1
          End Select

          'cmbTableActionStatusVariable
          cmbTableActionStatusVariable.SelectedIndex = FindIndexForVariableComboBox("cmbTableActionStatusVariable", _oAuditConfig.AuditTableExecutionVariableName)
     End Sub

     Private Function FindIndexForVariableComboBox(ByVal ComboBoxName As String, ByVal VariableName As String) As Integer
          Dim _oComboBox As ComboBox
          Dim _oVariable As AuditVariable
          Dim _iPos As Integer
          Dim _sCondComboBoxName As String = ComboBoxName.Trim
          Dim _sCondVariableName As String = VariableName.Trim

          _oComboBox = CType(FindControlOnForm(Me.Controls, _sCondComboBoxName), ComboBox)

          'We didn't find the combo box so we are saying that it is unselected..
          If _oComboBox Is Nothing Then Return -1

          If _sCondVariableName = "" Then Return _oComboBox.Items.IndexOf(_oUnselectedVariableObject)

          'Iterate through the items in the combobox to try and find it.
          For _iPos = 0 To _oComboBox.Items.Count - 1
               _oVariable = CType(_oComboBox.Items(_iPos), AuditVariable)

               If _oVariable.VariableName = _sCondVariableName Then
                    Return _iPos
               End If
          Next

          'We Did not find a variable matching so we choose the unselected one
          Return _oComboBox.Items.IndexOf(_oUnselectedVariableObject)
     End Function

     Public Function FindControlOnForm(ByVal Controls As Control.ControlCollection, ByVal ControlName As String) As Control
          Dim _oControl As Control
          Dim _oControlIn As Control

          For Each _oControl In Controls
               Debug.WriteLine("In Control: " & _oControl.Name)

               If _oControl.Name = ControlName Then
                    Return _oControl
               Else
                    If _oControl.Controls.Count > 0 Then
                         Debug.WriteLine("In Sub Control: " & _oControl.Name)

                         'Return FindControlOnForm(_oControl.Controls, ControlName)
                         _oControlIn = FindControlOnForm(_oControl.Controls, ControlName)

                         If Not _oControlIn Is Nothing Then
                              If _oControlIn.Name = ControlName Then
                                   Return _oControlIn
                              End If
                         End If
                    End If
               End If
          Next

          'If you have gotten to this point then it was not found..
          Return Nothing
     End Function
#End Region

#Region "Sub-State Control"
#Region "Handle Major States of Sections"
     Private Sub cmbAuditPackageExecutionMode_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbAuditPackageExecutionMode.SelectedIndexChanged
          Select Case cmbAuditPackageExecutionMode.SelectedIndex
               Case 0 'Package Execution Start
                    rbRunAsMasterYes.Enabled = True
                    rbRunAsMasterNo.Enabled = True
                    rbRunAsMasterAlways.Enabled = True
                    cmbParentPackageExecutionIdVariable.Enabled = True
                    cmbThisPackageExecutionIdVariable.Enabled = True
                    cmbPackageExecutionStatus.Enabled = False
                    cmbPackageExecutionVariable.Enabled = False
               Case 1 'Package Execution End
                    rbRunAsMasterYes.Enabled = False
                    rbRunAsMasterNo.Enabled = False
                    rbRunAsMasterAlways.Enabled = False
                    cmbParentPackageExecutionIdVariable.Enabled = True
                    cmbThisPackageExecutionIdVariable.Enabled = True
                    cmbPackageExecutionStatus.Enabled = True
                    cmbPackageExecutionVariable.Enabled = True
               Case 2 'Not Auditing Package Execution
                    rbRunAsMasterYes.Enabled = False
                    rbRunAsMasterNo.Enabled = False
                    rbRunAsMasterAlways.Enabled = False
                    cmbParentPackageExecutionIdVariable.Enabled = False
                    cmbThisPackageExecutionIdVariable.Enabled = False
                    cmbPackageExecutionStatus.Enabled = False
                    cmbPackageExecutionVariable.Enabled = False
               Case Else
                    rbRunAsMasterYes.Enabled = False
                    rbRunAsMasterNo.Enabled = False
                    rbRunAsMasterAlways.Enabled = False
                    cmbParentPackageExecutionIdVariable.Enabled = False
                    cmbThisPackageExecutionIdVariable.Enabled = False
                    cmbPackageExecutionStatus.Enabled = False
                    cmbPackageExecutionVariable.Enabled = False
          End Select
     End Sub

     Private Sub cmbAuditTableExecutionMode_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbAuditTableExecutionMode.SelectedIndexChanged
          Select Case cmbAuditTableExecutionMode.SelectedIndex
               Case 0 'Start Table Audit
                    cmbAuditedDBConn.Enabled = True
                    cmbTableAuditKeyIdVariable.Enabled = True
                    cmbTableName.Enabled = True
                    cmbStartRowCountAction.Enabled = True
                    cmbUpdateRowCountVariable.Enabled = False
                    cmbInsertRowCountAction.Enabled = False
                    cmbDeleteRowCountVariable.Enabled = False
                    cmbErrorRowCountVariable.Enabled = False
                    cmbEndingRowCountAction.Enabled = False
                    cmbTableActionStatus.Enabled = False
                    cmbTableActionStatusVariable.Enabled = False
               Case 1 'End Table Audit
                    cmbAuditedDBConn.Enabled = True
                    cmbTableAuditKeyIdVariable.Enabled = True
                    cmbTableName.Enabled = True
                    cmbStartRowCountAction.Enabled = False
                    cmbUpdateRowCountVariable.Enabled = True
                    cmbInsertRowCountAction.Enabled = True
                    cmbDeleteRowCountVariable.Enabled = True
                    cmbErrorRowCountVariable.Enabled = True
                    cmbEndingRowCountAction.Enabled = True
                    cmbTableActionStatus.Enabled = True
                    cmbTableActionStatusVariable.Enabled = True
               Case 2 'Not Auditing Tables
                    cmbAuditedDBConn.Enabled = False
                    cmbTableAuditKeyIdVariable.Enabled = False
                    cmbTableName.Enabled = False
                    cmbStartRowCountAction.Enabled = False
                    cmbUpdateRowCountVariable.Enabled = False
                    cmbInsertRowCountAction.Enabled = False
                    cmbDeleteRowCountVariable.Enabled = False
                    cmbErrorRowCountVariable.Enabled = False
                    cmbEndingRowCountAction.Enabled = False
                    cmbTableActionStatus.Enabled = False
                    cmbTableActionStatusVariable.Enabled = False
               Case Else
                    cmbAuditedDBConn.Enabled = False
                    cmbTableAuditKeyIdVariable.Enabled = False
                    cmbTableName.Enabled = False
                    cmbStartRowCountAction.Enabled = False
                    cmbUpdateRowCountVariable.Enabled = False
                    cmbInsertRowCountAction.Enabled = False
                    cmbDeleteRowCountVariable.Enabled = False
                    cmbErrorRowCountVariable.Enabled = False
                    cmbEndingRowCountAction.Enabled = False
                    cmbTableActionStatus.Enabled = False
                    cmbTableActionStatusVariable.Enabled = False
          End Select
     End Sub
#End Region

#Region "Handle Run As Master Selectors"
     Private Sub rbRunAsMasterYes_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbRunAsMasterYes.CheckedChanged
          HandleRunAsMasterSelectors()
     End Sub

     Private Sub rbRunAsMasterNo_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbRunAsMasterNo.CheckedChanged
          HandleRunAsMasterSelectors()
     End Sub

     Private Sub rbRunAsMasterAlways_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbRunAsMasterAlways.CheckedChanged
          HandleRunAsMasterSelectors()
     End Sub

     Private Sub HandleRunAsMasterSelectors()
          If rbRunAsMasterYes.Checked = True Or rbRunAsMasterNo.Checked = True Then
               cmbParentPackageExecutionIdVariable.Enabled = True
          End If

          If rbRunAsMasterAlways.Checked = True Then
               cmbParentPackageExecutionIdVariable.Enabled = False
          End If
     End Sub
#End Region

#Region "Handle Row Count Action States"
     Private Sub cmbStartRowCountAction_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbStartRowCountAction.SelectedIndexChanged
          Select Case cmbStartRowCountAction.SelectedIndex
               Case 0 'Auto Count From Specified Table
                    lblStartRowCountVQ.Hide()
                    cmbStartRowCountVariable.Hide()
                    txtStartRowCountQuery.Hide()
                    btnStartRowCountDialog.Hide()
               Case 1 'Get From Variable
                    lblStartRowCountVQ.Text = "Variable:"
                    lblStartRowCountVQ.Show()
                    cmbStartRowCountVariable.Show()
                    txtStartRowCountQuery.Hide()
                    btnStartRowCountDialog.Hide()
               Case 2 'Get By Query
                    lblStartRowCountVQ.Text = "Query:"
                    lblStartRowCountVQ.Show()
                    cmbStartRowCountVariable.Hide()
                    txtStartRowCountQuery.Show()
                    btnStartRowCountDialog.Show()
               Case Else
                    lblStartRowCountVQ.Hide()
                    cmbStartRowCountVariable.Hide()
                    txtStartRowCountQuery.Hide()
                    btnStartRowCountDialog.Hide()
          End Select
     End Sub

     Private Sub cmbInsertRowCountAction_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbInsertRowCountAction.SelectedIndexChanged
          Select Case cmbInsertRowCountAction.SelectedIndex
               Case 0 'Auto Count From Specified Table
                    lblInsertRowCountVQ.Hide()
                    cmbInsertRowCountVariable.Hide()
                    txtInsertRowCountQuery.Hide()
                    btnInsertRowCountDialog.Hide()
               Case 1 'Get From Variable
                    lblInsertRowCountVQ.Text = "Variable:"
                    lblInsertRowCountVQ.Show()
                    cmbInsertRowCountVariable.Show()
                    txtInsertRowCountQuery.Hide()
                    btnInsertRowCountDialog.Hide()
               Case 2 'Get By Query
                    lblInsertRowCountVQ.Text = "Query:"
                    lblInsertRowCountVQ.Show()
                    cmbInsertRowCountVariable.Hide()
                    txtInsertRowCountQuery.Show()
                    btnInsertRowCountDialog.Show()
               Case Else
                    lblInsertRowCountVQ.Hide()
                    cmbInsertRowCountVariable.Hide()
                    txtInsertRowCountQuery.Hide()
                    btnInsertRowCountDialog.Hide()
          End Select
     End Sub

     Private Sub cmbEndingRowCountAction_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbEndingRowCountAction.SelectedIndexChanged
          Select Case cmbEndingRowCountAction.SelectedIndex
               Case 0 'Auto Count From Specified Table
                    lblEndingRowCountVQ.Hide()
                    cmbEndingRowCountVariable.Hide()
                    txtEndingRowCountQuery.Hide()
                    btnEndingRowCountDialog.Hide()
               Case 1 'Get From Variable
                    lblEndingRowCountVQ.Text = "Variable:"
                    lblEndingRowCountVQ.Show()
                    cmbEndingRowCountVariable.Show()
                    txtEndingRowCountQuery.Hide()
                    btnEndingRowCountDialog.Hide()
               Case 2 'Get By Query
                    lblEndingRowCountVQ.Text = "Query:"
                    lblEndingRowCountVQ.Show()
                    cmbEndingRowCountVariable.Hide()
                    txtEndingRowCountQuery.Show()
                    btnEndingRowCountDialog.Show()
               Case Else
                    lblEndingRowCountVQ.Hide()
                    cmbEndingRowCountVariable.Hide()
                    txtEndingRowCountQuery.Hide()
                    btnEndingRowCountDialog.Hide()
          End Select
     End Sub
#End Region

#Region "Handle Execution Status States"
     Private Sub cmbPackageExecutionStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbPackageExecutionStatus.SelectedIndexChanged
          Select Case cmbPackageExecutionStatus.SelectedIndex
               Case 0 'Package Executed Successfully
                    lblPackageExecutionVariable.Hide()
                    cmbPackageExecutionVariable.Hide()
               Case 1 'Package Failed Execution
                    lblPackageExecutionVariable.Hide()
                    cmbPackageExecutionVariable.Hide()
               Case 2 'Execution Status In Variable (Pass 0/1, Y/N)
                    lblPackageExecutionVariable.Show()
                    cmbPackageExecutionVariable.Show()
               Case Else
                    lblPackageExecutionVariable.Hide()
                    cmbPackageExecutionVariable.Hide()
          End Select
     End Sub

     Private Sub cmbPackageExecutionVariable_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPackageExecutionVariable.SelectedIndexChanged

     End Sub

     Private Sub cmbTableActionStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTableActionStatus.SelectedIndexChanged
          Select Case cmbTableActionStatus.SelectedIndex
               Case 0 'Table Processing Was Successful
                    lblTableActionStatusVariable.Hide()
                    cmbTableActionStatusVariable.Hide()
               Case 1 'Table Processing Failed
                    lblTableActionStatusVariable.Hide()
                    cmbTableActionStatusVariable.Hide()
               Case 2 'Execution Status In Variable (Pass 0/1, Y/N)
                    lblTableActionStatusVariable.Show()
                    cmbTableActionStatusVariable.Show()
               Case Else
                    lblTableActionStatusVariable.Hide()
                    cmbTableActionStatusVariable.Hide()
          End Select
     End Sub

     Private Sub cmbTableActionStatusVariable_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbTableActionStatusVariable.SelectedIndexChanged

     End Sub
#End Region

#Region "Handle Table Name Dropdown and Population"
     Private Sub cmbTableName_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTableName.DropDown
          If _oTableListPopulated = False Then 'We haven't populated the list yet
               If cmbAuditedDBConn.SelectedIndex = -1 Then 'A connection has not been selected so we can't get a table list
                    MsgBox("Please select a connection for the database that is being audited.", MsgBoxStyle.OkOnly, "Please Select Database Connection")
               Else 'We have selected a connection so we can now fill the combobox
                    PopulateTableNameDropDown()
               End If
          Else 'We have populated the list so we don't really need to do anything..
          End If
     End Sub

     Private Sub cmbTableName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbTableName.SelectedIndexChanged
          Dim _oTable As AuditTable

          _oTable = CType(cmbTableName.SelectedItem, AuditTable)

          _oAuditConfig.AuditTableSchemaName = _oTable.TableSchemaName
          _oAuditConfig.AuditTableName = _oTable.TableName
     End Sub

     Private Sub btnRefreshTableList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefreshTableList.Click
          _oTableListPopulated = False
          PopulateTableNameDropDown()
     End Sub

     Private Sub PopulateTableNameDropDown()
          Try
               Dim _oConnection As AuditConnection
               Dim _sQueryString As String = "SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'"

               'cmbTableName.Items.Clear() 'Clear the combobox
               _oAuditTables.Clear() 'Clear the object

               _oConnection = CType(cmbAuditedDBConn.SelectedItem, AuditConnection)

               'Make sure the connection is of a supported type.
               If Not _oConnection.ConnectionType = "OLEDB" And Not _oConnection.ConnectionType = "ADO.NET" Then
                    Throw New ApplicationException("Selected Connection is not of the correct type, only OLEDB and ADO.NET connections are supported.")
                    Exit Sub
               End If

               'SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
               'TABLE_SCHEMA	TABLE_NAME
               'dbo			WorkTable1
               'dbo			WorkTable2

               If _oConnection.ConnectionType = "OLEDB" Then
                    Dim _oOleDbConnection As OleDbConnection
                    Dim _oOleDbCommand As OleDbCommand
                    Dim _oDataReader As OleDbDataReader

                    _oOleDbConnection = New OleDbConnection(_oConnection.ConnectionString)
                    _oOleDbCommand = New OleDbCommand(_sQueryString, _oOleDbConnection)
                    _oOleDbConnection.Open()
                    _oDataReader = _oOleDbCommand.ExecuteReader()

                    Do While (_oDataReader.Read())
                         _oAuditTables.Add(_oDataReader.GetString(0), _oDataReader.GetString(1))

                         'cmbTableName.Items.Add(_oDataReader.GetString(0) & "." & _oDataReader.GetString(1))

                         'If (_oDataReader.IsDBNull(4)) Then
                         '     Console.Write("N/A" + Chr(10))
                         'Else
                         '     Console.Write(_oDataReader.GetInt32(4).ToString() + Chr(10))
                         'End If
                    Loop

                    _oDataReader.Close()
                    _oOleDbConnection.Close()
               ElseIf _oConnection.ConnectionType = "ADO.NET" Then
                    Dim _oADONETConnection As SqlConnection
                    Dim _oADONETCommand As SqlDataAdapter
                    Dim _oADONETDataSet As New DataSet()
                    Dim _oADONETDataTable As DataTable
                    Dim _oADONETDataRow As DataRow

                    _oADONETConnection = New SqlConnection(_oConnection.ConnectionString)
                    _oADONETCommand = New SqlDataAdapter(_sQueryString, _oADONETConnection)
                    _oADONETCommand.Fill(_oADONETDataSet)
                    _oADONETDataTable = _oADONETDataSet.Tables(0)

                    For Each _oADONETDataRow In _oADONETDataTable.Rows
                         _oAuditTables.Add(_oADONETDataRow.Item(0).ToString(), _oADONETDataRow.Item(1).ToString())
                    Next

                    _oADONETConnection.Close()
               End If

               If _oAuditTables.Count > 0 Then
                    _oTableListPopulated = True
                    btnRefreshTableList.Show()
               Else
                    _oTableListPopulated = False
                    btnRefreshTableList.Hide()
               End If
          Catch ex As Exception
               MsgBox("Exception: " & ex.ToString, MsgBoxStyle.OkOnly, "PopulateTableNameDropDown Exception")

               'cmbTableName.Items.Clear() 'Clear the combobox
               _oAuditTables.Clear() 'Clear the object
               _oTableListPopulated = False
               btnRefreshTableList.Hide()
          End Try
     End Sub
#End Region
#End Region
#End Region

#Region "Populate Global Container Variables"
     Private Sub GetConnectionsFromPackage()
          Dim _oConnections As Connections
          Dim _oConnection As ConnectionManager

          _oConnections = _oPkg.Connections

          '_oConnection.CreationName = "ADO.NET:System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          For Each _oConnection In _oConnections
               If _oConnection.CreationName = "OLEDB" Then
                    '_oAuditConnections.Add(_oConnection.Name, _oConnection.ID, _oConnection.ConnectionString)
                    _oAuditAuditDBConnConnections.Add(_oConnection.Name, _oConnection.ID, _oConnection.ConnectionString, "OLEDB")
                    _oAuditAuditedDBConnConnections.Add(_oConnection.Name, _oConnection.ID, _oConnection.ConnectionString, "OLEDB")
               ElseIf _oConnection.CreationName.IndexOf("ADO.NET") = 0 Then
                    _oAuditAuditDBConnConnections.Add(_oConnection.Name, _oConnection.ID, _oConnection.ConnectionString, "ADO.NET")
                    _oAuditAuditedDBConnConnections.Add(_oConnection.Name, _oConnection.ID, _oConnection.ConnectionString, "ADO.NET")
               End If
          Next
     End Sub

     Private Sub GetIntVariablesFromPackage()
          Dim _oVariable As Variable
          Dim _oVariables As Variables

          _oVariables = _taskHostValue.Variables

          'Add the unselected member
          _oAuditParentPackageExecutionIdVariables.Add(_oUnselectedVariableObject)
          _oAuditThisPackageExecutionIdVariables.Add(_oUnselectedVariableObject)
          _oAuditTableAuditKeyIdVariables.Add(_oUnselectedVariableObject)
          _oAuditStartRowCountVariables.Add(_oUnselectedVariableObject)
          _oAuditInsertRowCountVariables.Add(_oUnselectedVariableObject)
          _oAuditUpdateRowCountVariables.Add(_oUnselectedVariableObject)
          _oAuditDeleteRowCountVariables.Add(_oUnselectedVariableObject)
          _oAuditErrorRowCountVariables.Add(_oUnselectedVariableObject)
          _oAuditEndingRowCountVariables.Add(_oUnselectedVariableObject)

          'Iterate through the variables object
          For Each _oVariable In _oVariables
               If _oVariable.DataType = TypeCode.Int32 And _oVariable.EvaluateAsExpression = False And _oVariable.SystemVariable = False Then
                    '_oAuditIntVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditParentPackageExecutionIdVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditThisPackageExecutionIdVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditTableAuditKeyIdVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditStartRowCountVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditInsertRowCountVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditUpdateRowCountVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditDeleteRowCountVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditErrorRowCountVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditEndingRowCountVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
               End If
          Next
     End Sub

     Private Sub GetMixedVariablesFromPackage()
          Dim _oVariable As Variable
          Dim _oVariables As Variables

          _oVariables = _taskHostValue.Variables

          'Add the unselected member
          _oAuditPackageExecutionVariables.Add(_oUnselectedVariableObject)
          _oAuditTableActionStatusVariables.Add(_oUnselectedVariableObject)

          'Iterate through the variables object
          For Each _oVariable In _oVariables
               If (_oVariable.DataType = TypeCode.Int32 Or _oVariable.DataType = TypeCode.Char _
                   Or _oVariable.DataType = TypeCode.String Or _oVariable.DataType = TypeCode.Byte) _
                  And _oVariable.EvaluateAsExpression = False _
                  And _oVariable.SystemVariable = False Then
                    '_oAuditMixedVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditPackageExecutionVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
                    _oAuditTableActionStatusVariables.Add(_oVariable.Name, _oVariable.ID, _oVariable.Namespace, _oVariable.QualifiedName)
               End If
          Next
     End Sub

     'Private Sub GenConnectionContainers()
     '     'cmbAuditDBConn
     '     _oAuditAuditDBConnConnections = CType(_oAuditConnections.Clone, AuditConnections)
     '     'cmbAuditedDBConn
     '     _oAuditAuditedDBConnConnections = CType(_oAuditConnections.Clone, AuditConnections)
     'End Sub

     'Private Sub GenVariableContainers()
     '     'cmbParentPackageExecutionIdVariable
     '     _oAuditParentPackageExecutionIdVariables = _oAuditIntVariables

     '     'cmbThisPackageExecutionIdVariable
     '     _oAuditThisPackageExecutionIdVariables = _oAuditIntVariables

     '     'cmbPackageExecutionVariable
     '     _oAuditPackageExecutionVariables = _oAuditMixedVariables

     '     'cmbTableAuditKeyIdVariable
     '     _oAuditTableAuditKeyIdVariables = _oAuditIntVariables

     '     'cmbStartRowCountVariable
     '     _oAuditStartRowCountVariables = _oAuditIntVariables

     '     'cmbInsertRowCountVariable
     '     _oAuditInsertRowCountVariables = _oAuditIntVariables

     '     'cmbUpdateRowCountVariable
     '     _oAuditUpdateRowCountVariables = _oAuditIntVariables

     '     'cmbDeleteRowCountVariable
     '     _oAuditDeleteRowCountVariables = _oAuditIntVariables

     '     'cmbErrorRowCountVariable
     '     _oAuditErrorRowCountVariables = _oAuditIntVariables

     '     'cmbEndingRowCountVariable
     '     _oAuditEndingRowCountVariables = _oAuditIntVariables

     '     'cmbTableActionStatusVariable
     '     _oAuditTableActionStatusVariables = _oAuditMixedVariables
     'End Sub
#End Region

#Region "DB Schema Show And Verification"
     Private Sub btnVerifyDBSchema_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVerifyDBSchema.Click

     End Sub

     Private Sub btnShowAuditDBSchema_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowAuditDBSchema.Click
          Dim _sQuery As String

          Dim _oAssembly As System.Reflection.[Assembly] = System.Reflection.[Assembly].GetExecutingAssembly()
          Dim strm As System.IO.Stream = _oAssembly.GetManifestResourceStream("NCL.SSIS.ControlFlow.AuditDBSchema.sql")
          Dim _oReader As New System.IO.StreamReader(strm)

          _sQuery = _oReader.ReadToEnd()

          _oReader.Close()

          HandleQueryDialog("Please Execute This Script In The Selected Audit DB", _sQuery)
     End Sub
#End Region

#Region "Handle Property Update -- Clicked OK"
     Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
          UpdateAuditConfigFromScreen()

          '_taskHostValue.InnerObject.AuditConfiguration = _oAuditConfig


          '_taskHostValue.Properties("AuditConfig").SetValue(_taskHostValue, _oAuditConfig)

          Me.DialogResult = Windows.Forms.DialogResult.OK
          Me.Close()
     End Sub

     Private Sub UpdateAuditConfigFromScreen()
          Dim _oAuditConnection As AuditConnection
          Dim _oAuditVariable As AuditVariable

          'DB Connections
          _oAuditConnection = CType(cmbAuditDBConn.SelectedItem, AuditConnection)

          If _oAuditConnection Is Nothing Then
               _oAuditConfig.AuditDatabaseConnectionName = ""
               _oAuditConfig.AuditDatabaseConnectionGUID = ""
          Else
               _oAuditConfig.AuditDatabaseConnectionName = _oAuditConnection.ConnectionName
               _oAuditConfig.AuditDatabaseConnectionGUID = _oAuditConnection.ConnectionGUID
          End If

          _oAuditConnection = CType(cmbAuditedDBConn.SelectedItem, AuditConnection)

          If _oAuditConnection Is Nothing Then
               _oAuditConfig.AuditedDatabaseConnectionName = ""
               _oAuditConfig.AuditedDatabaseConnectionGUID = ""
          Else
               _oAuditConfig.AuditedDatabaseConnectionName = _oAuditConnection.ConnectionName
               _oAuditConfig.AuditedDatabaseConnectionGUID = _oAuditConnection.ConnectionGUID
          End If

          'Package Auditing Execution Mode
          Select Case cmbAuditPackageExecutionMode.SelectedIndex
               Case 0 'Package Execution Start
                    _oAuditConfig.AuditPackageExecutionMode = AuditExecutionMode.ExecStart
               Case 1 'Package Execution End
                    _oAuditConfig.AuditPackageExecutionMode = AuditExecutionMode.ExecEnd
               Case 2 'Not Auditing Package Execution
                    _oAuditConfig.AuditPackageExecutionMode = AuditExecutionMode.None
               Case Else
                    _oAuditConfig.AuditPackageExecutionMode = AuditExecutionMode.None
          End Select

          'Table Auditing Execution Mode
          Select Case cmbAuditTableExecutionMode.SelectedIndex
               Case 0 'Start Table Audit
                    _oAuditConfig.AuditTableExecutionMode = AuditExecutionMode.ExecStart
               Case 1 'End Table Audit
                    _oAuditConfig.AuditTableExecutionMode = AuditExecutionMode.ExecEnd
               Case 2 'Not Auditing Tables
                    _oAuditConfig.AuditTableExecutionMode = AuditExecutionMode.None
               Case Else
                    _oAuditConfig.AuditTableExecutionMode = AuditExecutionMode.None
          End Select

          'Handle run as master setup
          If rbRunAsMasterYes.Checked = True And rbRunAsMasterNo.Checked = False And rbRunAsMasterAlways.Checked = False Then
               _oAuditConfig.AuditPackageRunAsMaster = AuditRunAsMaster.Yes
          End If

          If rbRunAsMasterYes.Checked = False And rbRunAsMasterNo.Checked = True And rbRunAsMasterAlways.Checked = False Then
               _oAuditConfig.AuditPackageRunAsMaster = AuditRunAsMaster.No
          End If

          If rbRunAsMasterYes.Checked = False And rbRunAsMasterNo.Checked = False And rbRunAsMasterAlways.Checked = True Then
               _oAuditConfig.AuditPackageRunAsMaster = AuditRunAsMaster.Always
          End If

          If rbRunAsMasterYes.Checked = False And rbRunAsMasterNo.Checked = False And rbRunAsMasterAlways.Checked = False Then
               _oAuditConfig.AuditPackageRunAsMaster = AuditRunAsMaster.No
          End If

          'Execution Ids
          '_oAuditConfig.AuditParentPackageExecutionIdVariableName = CType(cmbParentPackageExecutionIdVariable.SelectedValue, AuditVariable).VariableName
          _oAuditVariable = CType(cmbParentPackageExecutionIdVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditParentPackageExecutionIdVariableName = ""
          Else
               _oAuditConfig.AuditParentPackageExecutionIdVariableName = _oAuditVariable.VariableName
          End If

          '_oAuditConfig.AuditThisPackageExecutionIdVariableName = CType(cmbThisPackageExecutionIdVariable.SelectedValue, AuditVariable).VariableName
          _oAuditVariable = CType(cmbThisPackageExecutionIdVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditThisPackageExecutionIdVariableName = ""
          Else
               _oAuditConfig.AuditThisPackageExecutionIdVariableName = _oAuditVariable.VariableName
          End If


          'Still have work here....
          'Still have work here....
          'Still have work here....
          'Still have work here....
          'Still have work here....

          '_oAuditConfig.AuditTableExecutionIdVariableName = CType(cmbTableAuditKeyIdVariable.SelectedValue, AuditVariable).VariableName
          _oAuditVariable = CType(cmbTableAuditKeyIdVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableExecutionIdVariableName = ""
          Else
               _oAuditConfig.AuditTableExecutionIdVariableName = _oAuditVariable.VariableName
          End If

          'Row Count Actions
          Select Case cmbStartRowCountAction.SelectedIndex
               Case 0 'Auto Count From Specified Table
                    _oAuditConfig.AuditTableStartRowCountAction = AuditTableAction.AutoCount
               Case 1 'Get From Variable
                    _oAuditConfig.AuditTableStartRowCountAction = AuditTableAction.GetCountFromVariable
               Case 2 'Get By Query
                    _oAuditConfig.AuditTableStartRowCountAction = AuditTableAction.GetCountByQuery
               Case Else
                    _oAuditConfig.AuditTableStartRowCountAction = AuditTableAction.AutoCount
          End Select

          Select Case cmbInsertRowCountAction.SelectedIndex
               Case 0 'Auto Count From Specified Table
                    _oAuditConfig.AuditTableInsertRowCountAction = AuditTableAction.AutoCount
               Case 1 'Get From Variable
                    _oAuditConfig.AuditTableInsertRowCountAction = AuditTableAction.GetCountFromVariable
               Case 2 'Get By Query
                    _oAuditConfig.AuditTableInsertRowCountAction = AuditTableAction.GetCountByQuery
               Case Else
                    _oAuditConfig.AuditTableInsertRowCountAction = AuditTableAction.AutoCount
          End Select

          Select Case cmbEndingRowCountAction.SelectedIndex
               Case 0 'Auto Count From Specified Table
                    _oAuditConfig.AuditTableEndingRowCountAction = AuditTableAction.AutoCount
               Case 1 'Get From Variable
                    _oAuditConfig.AuditTableEndingRowCountAction = AuditTableAction.GetCountFromVariable
               Case 2 'Get By Query
                    _oAuditConfig.AuditTableEndingRowCountAction = AuditTableAction.GetCountByQuery
               Case Else
                    _oAuditConfig.AuditTableEndingRowCountAction = AuditTableAction.AutoCount
          End Select

          ''Row Count Variables
          '_oAuditConfig.AuditTableStartRowCountVariableName = CType(cmbStartRowCountVariable.SelectedValue, String)
          _oAuditVariable = CType(cmbStartRowCountVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableStartRowCountVariableName = ""
          Else
               _oAuditConfig.AuditTableStartRowCountVariableName = _oAuditVariable.VariableName
          End If

          '_oAuditConfig.AuditTableInsertRowCountVariableName = CType(cmbInsertRowCountVariable.SelectedValue, String)
          _oAuditVariable = CType(cmbInsertRowCountVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableInsertRowCountVariableName = ""
          Else
               _oAuditConfig.AuditTableInsertRowCountVariableName = _oAuditVariable.VariableName
          End If

          '_oAuditConfig.AuditTableUpdateRowCountVariableName = CType(cmbUpdateRowCountVariable.SelectedValue, String)
          _oAuditVariable = CType(cmbUpdateRowCountVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableUpdateRowCountVariableName = ""
          Else
               _oAuditConfig.AuditTableUpdateRowCountVariableName = _oAuditVariable.VariableName
          End If

          '_oAuditConfig.AuditTableDeleteRowCountVariableName = CType(cmbDeleteRowCountVariable.SelectedValue, String)
          _oAuditVariable = CType(cmbDeleteRowCountVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableDeleteRowCountVariableName = ""
          Else
               _oAuditConfig.AuditTableDeleteRowCountVariableName = _oAuditVariable.VariableName
          End If

          '_oAuditConfig.AuditTableErrorRowCountVariableName = CType(cmbErrorRowCountVariable.SelectedValue, String)
          _oAuditVariable = CType(cmbErrorRowCountVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableErrorRowCountVariableName = ""
          Else
               _oAuditConfig.AuditTableErrorRowCountVariableName = _oAuditVariable.VariableName
          End If

          '_oAuditConfig.AuditTableEndingRowCountVariableName = CType(cmbEndingRowCountVariable.SelectedValue, String)
          _oAuditVariable = CType(cmbEndingRowCountVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableEndingRowCountVariableName = ""
          Else
               _oAuditConfig.AuditTableEndingRowCountVariableName = _oAuditVariable.VariableName
          End If

          'Execution Status Values
          Select Case cmbPackageExecutionStatus.SelectedIndex
               Case 0 'Package Executed Successfully
                    _oAuditConfig.AuditPackageExecutionStatus = AuditExecutionStatus.Success
               Case 1 'Package Failed Execution
                    _oAuditConfig.AuditPackageExecutionStatus = AuditExecutionStatus.Fail
               Case 2 'Execution Status In Variable (Pass 0/1, Y/N)
                    _oAuditConfig.AuditPackageExecutionStatus = AuditExecutionStatus.GetFromVariable
               Case Else
                    _oAuditConfig.AuditPackageExecutionStatus = AuditExecutionStatus.Fail
          End Select

          Select Case cmbTableActionStatus.SelectedIndex
               Case 0 'Table Processing Was Successful
                    _oAuditConfig.AuditTableExecutionStatus = AuditExecutionStatus.Success
               Case 1 'Table Processing Failed
                    _oAuditConfig.AuditTableExecutionStatus = AuditExecutionStatus.Fail
               Case 2 'Execution Status In Variable (Pass 0/1, Y/N)
                    _oAuditConfig.AuditTableExecutionStatus = AuditExecutionStatus.GetFromVariable
               Case Else
                    _oAuditConfig.AuditTableExecutionStatus = AuditExecutionStatus.Fail
          End Select

          'Execution Status Variables
          '_oAuditConfig.AuditPackageExecutionVariableName = CType(cmbPackageExecutionVariable.SelectedItem, AuditVariable).VariableName
          _oAuditVariable = CType(cmbPackageExecutionVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditPackageExecutionVariableName = ""
          Else
               _oAuditConfig.AuditPackageExecutionVariableName = _oAuditVariable.VariableName
          End If

          '_oAuditConfig.AuditTableExecutionVariableName = CType(cmbTableActionStatusVariable.SelectedItem, AuditVariable).VariableName
          _oAuditVariable = CType(cmbTableActionStatusVariable.SelectedItem, AuditVariable)
          If _oAuditVariable.Equals(_oUnselectedVariableObject) = True Then
               _oAuditConfig.AuditTableExecutionVariableName = ""
          Else
               _oAuditConfig.AuditTableExecutionVariableName = _oAuditVariable.VariableName
          End If


          '----------------------------------
          'Cleanup the config that is written 
          _oAuditConfig.CleanConfig()

          '---------------------------------------------
          'Populate the Task Host from the config object
          PopulateTaskHostPropertiesFromAuditConfig()
     End Sub
#End Region

#Region "Handle Cancel -- Clicked Cancel"
     Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

     End Sub
#End Region

#Region "Handle DB Connection Changes"
     Private Sub cmbAuditDBConn_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAuditDBConn.SelectedIndexChanged

     End Sub

     Private Sub cmbAuditedDBConn_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAuditedDBConn.SelectedIndexChanged

     End Sub
#End Region

#Region "Handle Query Dialog"
     Private Sub btnStartRowCountDialog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartRowCountDialog.Click
          Dim _sQueryString As String

          _sQueryString = HandleQueryDialog("Edit Query - Starting Row Count", txtStartRowCountQuery.Text)

          txtStartRowCountQuery.Text = _sQueryString
          _oAuditConfig.AuditTableStartRowCountQuery = _sQueryString
     End Sub

     Private Sub btnInsertRowCountDialog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertRowCountDialog.Click
          Dim _sQueryString As String

          _sQueryString = HandleQueryDialog("Edit Query - Insert Row Count", txtInsertRowCountQuery.Text)

          txtInsertRowCountQuery.Text = _sQueryString
          _oAuditConfig.AuditTableInsertRowCountQuery = _sQueryString
     End Sub

     Private Sub btnEndingRowCountDialog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEndingRowCountDialog.Click
          Dim _sQueryString As String

          _sQueryString = HandleQueryDialog("Edit Query - Ending Row Count", txtEndingRowCountQuery.Text)

          txtEndingRowCountQuery.Text = _sQueryString
          _oAuditConfig.AuditTableEndingRowCountQuery = _sQueryString
     End Sub

     Private Function HandleQueryDialog(ByVal QueryName As String, ByVal QueryString As String) As String
          Dim _oDialog As New QueryDialog
          Dim _oDialogResult As DialogResult
          Dim _sQueryString As String

          _sQueryString = QueryString
          _oDialog.rtbQuery.Text = _sQueryString
          _oDialog.Text = _oDialog.Text & " - " & QueryName

          _oDialogResult = _oDialog.ShowDialog

          'Evaluate Result
          If _oDialogResult = Windows.Forms.DialogResult.OK Or _oDialogResult = Windows.Forms.DialogResult.Yes Then
               _sQueryString = _oDialog.rtbQuery.Text
          End If

          _oDialog.Hide()
          _oDialog = Nothing

          Return _sQueryString
     End Function
#End Region

#Region "General Helper Code"

#End Region
End Class

'          'Variables
'          Debug.WriteLine("Variable Count: " & _taskHostValue.Variables.Count)
'          Debug.WriteLine("--Variables----------------------------------------------------")
'
'          Dim _oVariable As Variable
'
'          For Each _oVariable In _taskHostValue.Variables
'               Debug.WriteLine("CreationName: " & _oVariable.CreationName)
'               Debug.WriteLine("DataType: " & _oVariable.DataType)
'               Debug.WriteLine("Description: " & _oVariable.Description)
'               Debug.WriteLine("EvaluateAsExpression: " & _oVariable.EvaluateAsExpression)
'               Debug.WriteLine("Expression: " & _oVariable.Expression)
'               Debug.WriteLine("ID: " & _oVariable.ID)
'               Debug.WriteLine("Name: " & _oVariable.Name)
'               Debug.WriteLine("Namespace: " & _oVariable.Namespace)
'               Debug.WriteLine("QualifiedName: " & _oVariable.QualifiedName)
'               Debug.WriteLine("ReadOnly: " & _oVariable.ReadOnly)
'               Debug.WriteLine("SystemVariable: " & _oVariable.SystemVariable)
'               Debug.WriteLine("ToString: " & _oVariable.ToString)
'               Debug.WriteLine("Value: " & _oVariable.Value.ToString)
'               Debug.WriteLine("---------------------------------------------------------------")
'          Next

'          'Properties
'          Dim _oProperties As DtsProperties
'          Dim _oProperty As DtsProperty
'          _oProperties = _taskHostValue.Properties

'          Debug.WriteLine("--Properties---------------------------------------------------")
'          For Each _oProperty In _oProperties
'               Debug.WriteLine("ConnectionType: " & _oProperty.ConnectionType)
'               Debug.WriteLine("Name: " & _oProperty.Name)
'               Debug.WriteLine("PropertyKind: " & _oProperty.PropertyKind)
'               Debug.WriteLine("Type: " & _oProperty.Type)
'               Debug.WriteLine("TypeConverter: " & _oProperty.TypeConverter)
'               Debug.WriteLine("UITypeEditor: " & _oProperty.UITypeEditor)
'               Debug.WriteLine("---------------------------------------------------------------")
'          Next


'cmbAuditDBConn

'cmbAuditPackageExecutionMode
'rbRunAsMasterYes
'rbRunAsMasterNo
'rbRunAsMasterYes
'cmbParentPackageExecutionIdVariable
'cmbThisPackageExecutionIdVariable
'cmbPackageExecutionStatus
'cmbPackageExecutionVariable

'cmbAuditTableExecutionMode
'cmbAuditedDBConn
'cmbTableAuditKeyIdVariable
'cmbTableName
'cmbStartRowCountAction
'cmbStartRowCountVariable
'txtStartRowCountQuery
'cmbUpdateRowCountVariable
'cmbInsertRowCountAction
'cmbInsertRowCountVariable
'txtInsertRowCountQuery
'cmbDeleteRowCountVariable
'cmbErrorRowCountVariable
'cmbEndingRowCountAction
'cmbEndingRowCountVariable
'txtEndingRowCountQuery
'cmbTableActionStatus
'cmbTableActionStatusVariable
